#pragma once

#include "base_util/utils.h"
#include "common/total_struct.h"
#include "common/common_tool.h"
#include "activate_code/activate_code.h"
#include "app/base_struct.h"

namespace app {

using namespace httplib;
using namespace common;

algo::CameraGroup parse_cameraGroup(Json::Value group_js);
int string_to_struct(const std::string& str, ConfigInfo& cfg_ifo, bool read_file=true);
int struct_to_string(ConfigInfo& cfg_ifo, std::string& str, bool write_file=true);

std::string get_machine_ip();
int check_rect_in_img(cv::Rect& rect, cv::Mat& img);

void make_mask(std::string type, std::string sub_type, cv::Mat& img, cv::Mat& mask_img, std::vector<cv::Point> region);

// void post_data_imp_v1(LogInfo *log_ifo, ConfigInfo* cfg_ifo, std::multimap<int64, algo::PostInfo>& cur_post_ifos);

void post_data_text_v2(LogInfo *log_ifo, ConfigInfo* cfg_ifo, std::multimap<int64, algo::PostInfo>& cur_post_ifos);

int check_register(LogInfo *log_ifo, ConfigInfo* cfg_ifo, ActivateCode* act_code);
int check_device(LogInfo *log_ifo, ConfigInfo* cfg_ifo, std::string local_ip, std::string serial_number, std::string secret_key);
int query_device(LogInfo *log_ifo, ConfigInfo* cfg_ifo, ActivateCode* act_code, std::string secret_key);

int find_camera_ip(std::string local_ip, std::vector<std::string>& camera_ips);

void send_local_heart(LogInfo *log_ifo, ConfigInfo* cfg_ifo);

}   // namespace smartbox
